package com.project.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.project.bean.MovieTicketBean;
import com.project.mapper.IMovieTicketMapper;

import com.project.service.IMovieTicketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class MovieTicketServiceImp implements IMovieTicketService {
    @Autowired
    private IMovieTicketMapper movieTicketMapper;


    @Override
    public IPage<MovieTicketBean> findByItem(Integer pageNO, String movieName, String cinemaName, String movieTime, Integer rowNumber) {
        QueryWrapper<MovieTicketBean> qw = new QueryWrapper<>();
        IPage<MovieTicketBean> page = new Page<>(pageNO, 3);
        if (movieName != null && !movieName.equals("")) {
            qw.eq("m_movieName", movieName);
        }
        if (cinemaName != null && !cinemaName.equals("")) {
            qw.eq("m_Cinema", cinemaName);
        }
        if (movieTime != null && !movieTime.equals("")) {
            qw.eq("m_movieTime", movieTime);
        }
        if (rowNumber != null && rowNumber >= 0) {
            qw.eq("m_rowNumber", rowNumber);
        }
        return movieTicketMapper.selectPage(page, qw);
    }
}
